{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <blockquote class="layui-elem-quote">
        1、用户名只能使用（字母，数字，-，_),<br>
        2、新添加用户,需登陆小程序手动验证后,才可以登陆账户!
    </blockquote>
    <div class="layui-card-header">
        <div class="layui-btn-group">
            {if auth_url('store/user/add')}
            <a href="{:url('store/user/add')}" class="layui-btn ajax-iframe" data-width="420px" data-height="523px">添加</a>
            {/if}
        </div>
    </div>

    <table id="tableList" lay-filter="tableList"></table>
    <!-- 表格操作列 -->
    <script type="text/html" id="tableTBTrack">
        {if auth_url('store/user/edit')}
        <a href="{:url('store/user/edit')}?id={{d.id}}" class="layui-btn layui-btn-sm ajax-iframe" data-width="420px" data-height="523px">修改</a>
        {/if}
        {if auth_url('store/user/del')}
        <a href="{:url('store/user/del')}?id={{d.id}}" class="layui-btn layui-btn-danger layui-btn-sm ajax-delete">删除</a>
        {/if}
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="status">
        <input type="checkbox" name="status" lay-skin="switch" lay-filter="*" lay-text="正常|锁定" data-url="{:url('store/user/edit')}?id={{d.id}}" {{d.status==1?'checked':''}}>
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="sort_order">
        <input type="text" name="sort_order" value="{{d.sort_order}}" autocomplete="off" class="layui-input ajax-update" data-url="{:url('store/user/edit')}?id={{d.id}}">
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="auth">
        {{# if(d.auth == '1'){ }}
        <a class="layui-btn layui-btn-primary layui-btn-sm">只查看本人</a>
        {{# }else if(d.auth == '2'){ }}
        <a class="layui-btn layui-btn-warm layui-btn-sm">查看本部门</a>
        {{# }else if(d.auth == '3'){ }}
        <a class="layui-btn layui-btn-normal layui-btn-sm">查看所有人</a>
        {{# } }}
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="verify">
        {{# if(d.is_verify == '1'){ }}
        <a class="layui-btn layui-btn-sm">已验证</a>
        {{# }else if(d.is_verify == '0'){ }}
        <a class="layui-btn layui-btn-warm layui-btn-sm">待验证</a>
        {{# } }}
    </script>

</div>
{/block}

{block name="js"}
<script>
    layui.use(['layer', 'form', 'table', 'util', 'dropdown'], function () {

        var table = layui.table;
        // 渲染回访表格
        var insTb = table.render({
            elem: '#tableList',
            url: "{:url('store/user/index_json')}",
            page: true,
            cellMinWidth: 100,
            limit:'15',
            limits:[15,30,50,100,200,500,1000],
            size:'lg',even:true,
            cols: [[
                {type:'numbers',title:'#'},
                {field: 'group_name', align: 'left', sort: true, title: '部门'},
                {field: 'name', align: 'left', sort: true, title: '姓名'},
                {field: 'mobile', align: 'left', sort: true, title: '手机号'},
                {field: 'create_time', align: 'center', sort: true, title: '创建时间'},
                {align: 'center', sort: false, title: '权限',templet:'#auth',width:120},
                {if auth_url('store/user/add')}
                {align: 'center', sort: false, title: '排序',templet:'#sort_order',width:100},
                {align: 'center', sort: false, title: '状态',templet:'#status',width:100},
                {/if}
                {align: 'center', toolbar: '#tableTBTrack', title: '操作', minWidth: 160}
            ]],
            parseData: function(res){ //res 即为原始返回的数据
                return {
                  "code": res.code, //解析接口状态
                  "msg": res.msg, //解析提示文本
                  "count": res.data.total, //解析数据长度
                  "data": res.data.data //解析数据列表
                };
            }
        });

    });

</script>
{/block}